<!-- 用户列表 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label">用户列表</p>
    <div class="mt10">
      <dxtable
        czWidth="240"
        :dataJson="dataJson"
        :portUrl="portUrl"
        :qx="qx"
        ref="databale"
      >
      </dxtable>
    </div>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../components/util/dxtable.vue";
import { dxget, dxpost, qurl, hf } from "../../util/index";
import { h, ref, reactive } from "vue";
import { NButton, NSwitch } from "naive-ui";
import expenseCalendar from "./list.vue";
const showModal = ref(false);
const openid = ref();
const initeer = () => {
  databale.value.initDataExpose();
};
const databale = ref();
// 弹窗公用该列表
let dataJson = reactive([
  {
    title: "openid",
    key: "openid",
    width: "220",
  },

  {
    title: "登录ip",
    key: "ip",
  },
  {
    title: "所在城市",
    key: "address",
    search: true,
  },
  {
    title: "手机号",
    key: "phone",
    search: true,
  },
  //   {
  //     title: "订单量",
  //     key: "",
  //   },
  //   {
  //     title: "消费金额",
  //     key: "",
  //   },
  {
    title: "状态",
    key: "state",
    search: true,
    type: "select",
    options: [
      {
        label: "全部",
        value: "",
      },
      {
        label: "正常",
        value: "1",
      },
      {
        label: "停用",
        value: "2",
      },
    ],
    render(row) {
      return h(NSwitch, {
        defaultValue: row.state == 1 ? true : false,
        onChange: async (data) => {
          await dxpost(
            portUrl,
            {
              id: row.id,
              state: data ? "1" : "2",
            },
            "put"
          );
          window.$message.success("操作成功！");
        },
      });
    },
  },
  {
    title: "最近访问时间",
    key: "recentVisitTime",
  },
  {
    title: "注册时间",
    key: "addTime",
  },
]);
const Userid = localStorage.id;
let portUrl = "dxgjAdmin/wxcharUser?Applicationid=" + Userid;
const qx = {
  DeletePermissionID: "riceuserListdel", //删除
  EditPermissionIdentifier: "riceuserListbj222", // 编辑
  NewPermissionIdentifier: "riceuserListxz", // 新建
  ViewPermissionID: "riceuserListck", // 查看
};
</script>
